<template>
  <div>
    <el-form-item label="显示密码图标" v-if="localData.type == 'password'">
      <el-switch v-model="localData.showPassword" />
    </el-form-item>
    <el-form-item label="前缀文本">
      <el-input v-model="localData.prepend" clearable placeholder="前缀" />
    </el-form-item>
    <el-form-item label="后缀文本">
      <el-input v-model="localData.append" clearable placeholder="后缀" />
    </el-form-item>
    <el-form-item label="文本长度">
      <div style="display:flex; gap:4px">
        <el-input-number v-model="localData.minlength" controls-position="right" placeholder="最小长度" />
        -
        <el-input-number v-model="localData.maxlength" controls-position="right" placeholder="最大长度"
        /></div>
    </el-form-item>
    <el-form-item label="是否可清空">
      <el-switch v-model="localData.clearable" />
    </el-form-item>
    <el-form-item label="前缀图标">
      <avue-input-icon v-model="localData.prefixIcon" :icon-list="elIconList" placeholder="图标" />
    </el-form-item>
    <el-form-item label="后缀图标">
      <avue-input-icon v-model="localData.suffixIcon" :icon-list="elIconList" placeholder="图标" />
    </el-form-item>
    <el-form-item label="显示计数" v-if="localData.maxlength">
      <el-switch v-model="localData.showWordLimit" />
    </el-form-item>
  </div>
</template>
<script>
import { elIconList } from '@code/components/anvil-code-low-common/utils/avueIconList'

export default {
  name: 'ConfigInput',
  props: {
    data: {
      type: Object,
      default: () => {}
    },
    formJson: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      showFormula: false,
      options: [
        {
          value: 1,
          label: '公式编辑'
        }
      ],
      localData: {},
      elIconList
    };
  },
  watch: {
    data: {
      handler(newVal) {
        if (newVal) {
          this.localData = newVal;
        }
      },
      deep: true,
      immediate: true
    },
    localData: {
      handler(newVal) {
        this.$emit('update:data', newVal);
      },
      deep: true
    }
  },
  methods: {
    closeEditFormula() {
      this.showFormula = false;
    },
    editFormula() {
      this.showFormula = true;
    }
  }
};
</script>
